//
//  HNSH_PopupController.h
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/27.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

// 控制蒙版视图的样式
typedef NS_ENUM(NSUInteger, PopupMaskType) {
    PopupMaskTypeBlackBlur = 0, //黑色半透明模糊效果
    PopupMaskTypeWhiteBlur, // 白色半透明模糊效果
    PopupMaskTypeWhite, // 纯白色
    PopupMaskTypeClear, // 全透明
    PopupMaskTypeBlackTranslucent // 默认黑色半透明效果
};

// 控制弹出视图的显示位置
typedef NS_ENUM(NSUInteger, PopupLayoutType) {
    PopupLayoutTypeTop = 0, // 在顶部显示
    PopupLayoutTypeBottom,
    PopupLayoutTypeLeft,
    PopupLayoutTypeRight,
    PopupLayoutTypeCenter // 默认居中显示
};

// 控制弹出视图将以哪种样式呈现
typedef enum : NSUInteger {
    PopupSlideStyleFromTop = 0, // 从上部滑出
    PopupSlideStyleFromBottom, // 从底部滑出
    PopupSlideStyleFromLeft, // 从左部滑出
    PopupSlideStyleFromRight, // 从右部滑出
    PopupSlideStyleShrinkInOut1 = 4, // 轻微缩放效果
    PopupSlideStyleShrinkInOut2, // 从中心点扩大或收缩
    PopupSlideStyleFade, // 默认淡入淡出效果
    
//    PopupSlideStyleShrinkInOut __attribute__((deprecated("Use PopupSlideStyleShrinkInOut1"))) = 4
} PopupSlideStyle;


@protocol HNSH_PopupControllerDelegate;

@interface HNSH_PopupController : NSObject

@property (nonatomic, weak) id <HNSH_PopupControllerDelegate> _Nullable delegate;

/// 初始化并设置蒙版样式
+ (instancetype _Nullable )popupControllerWithMaskType:(PopupMaskType)maskType;

/// 自定义弹出View
@property (nonatomic, strong, readonly) UIView * _Nullable popupView;

/// Whether contentView is presenting.
@property (nonatomic, assign, readonly) BOOL isPresenting;

/// 弹出框位置（默认中间）
@property (nonatomic, assign) PopupLayoutType layoutType;

@property (nonatomic, assign) PopupSlideStyle slideStyle;

/// 设置蒙版alpha（默认0.5）
@property (nonatomic, assign) CGFloat maskAlpha;

/// 蒙版是否支持点击事件（默认YES）
@property (nonatomic, assign) BOOL dismissOnMaskTouched;

///
@property (nonatomic, assign) BOOL dismissOppositeDirection;

/// 内容视图是否支持拖拽手势
@property (nonatomic, assign) BOOL allowPan;

@property (nonatomic, assign) CGFloat offsetSpacingOfKeyboard;

- (void)dropAnimatedWithRotateAngle:(CGFloat)angle;

@property (nonatomic, copy) void (^ _Nullable maskTouched)(HNSH_PopupController * _Nullable popupController);

@property (nonatomic, copy) void (^ _Nullable willPresent)(HNSH_PopupController * _Nullable popupController);

@property (nonatomic, copy) void (^ _Nullable didPresent)(HNSH_PopupController * _Nullable popupController);

@property (nonatomic, copy) void (^ _Nullable willDismiss)(HNSH_PopupController * _Nullable popupController);

@property (nonatomic, copy) void (^ _Nullable didDismiss)(HNSH_PopupController * _Nullable popupController);



- (void)presentContentView:(nullable UIView *)contentView
                  duration:(NSTimeInterval)duration
            springAnimated:(BOOL)isSpringAnimated
                    inView:(nullable UIView *)sView
               displayTime:(NSTimeInterval)displayTime;

- (void)presentContentView:(nullable UIView *)contentView
                  duration:(NSTimeInterval)duration
            springAnimated:(BOOL)isSpringAnimated
                    inView:(nullable UIView *)sView;

- (void)presentContentView:(nullable UIView *)contentView
                  duration:(NSTimeInterval)duration
            springAnimated:(BOOL)isSpringAnimated;

- (void)presentContentView:(nullable UIView *)contentView displayTime:(NSTimeInterval)displayTime;;

- (void)presentContentView:(nullable UIView *)contentView;


- (void)dismissWithDuration:(NSTimeInterval)duration springAnimated:(BOOL)isSpringAnimated;

- (void)dismiss;

- (void)fadeDismiss;

@end

@protocol HNSH_PopupControllerDelegate <NSObject>

@optional
- (void)popupControllerWillPresent:(nonnull HNSH_PopupController *)popupController;
- (void)popupControllerDidPresent:(nonnull HNSH_PopupController *)popupController;
- (void)popupControllerWillDismiss:(nonnull HNSH_PopupController *)popupController;
- (void)popupControllerDidDismiss:(nonnull HNSH_PopupController *)popupController;

@end

@interface UIViewController (HNSH_PopupController)

@property (nonatomic, strong) HNSH_PopupController * _Nullable HNSH_popupController;

@end

NS_ASSUME_NONNULL_END
